package com.xc.freeapp.account.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.xc.freeapp.bean.AuthInfo;
import com.xc.freeapp.entity.LeadPage;
import com.xc.freeapp.exception.BaseException;
import com.xc.freeapp.service.LeadPageService;
import com.xc.freeapp.util.AuthUtil;
import com.xc.freeapp.util.TokenAnnotation;
import com.xc.freeapp.util.UploadUtil;

@Controller
@RequestMapping("/leadpage")
@Api(value="/leadpage",description = "引导图")
public class LeadPageController extends AbstractController  {
	@Autowired
	private LeadPageService leadPageServiceImpl;
	
	@TokenAnnotation(required=false)
	@RequestMapping(value = "", method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation(value = "获取引导图")
	public  List<LeadPage> getLeadPageList(@RequestParam("version") String version) throws BaseException{
		AuthInfo authInfo = AuthUtil.getAuthInfo(getRequest());
	
		List<LeadPage> leadPagelists =leadPageServiceImpl.getLeadPage(authInfo.getAppIntId(), version);
		for (LeadPage leadPage : leadPagelists) {
			leadPage.setPath(UploadUtil.urlConversion(leadPage.getPath()));
		}
		return leadPagelists;
	}

}
